<extend name="Base/common"/>
<block name="style">
<link href="__CSS__/lyz.calendar.css" rel="stylesheet" type="text/css" />
<style type="text/css">
	p{
		width: 90%;
		height: 30px;
		line-height: 30px;
		text-align: left;
		margin-top:10px; 
		padding-bottom: 2%;
		color: #10AEFF;

	}
	p span{
		width: 25%;
		height: 40px;
		background: #EDEDED;
		border:1px solid #ccc;
		border-right: none;
		line-height: 40px;
		text-align: center;
		float: left;
	}


	table{

	font-size: 12px;

	font-family: "微软雅黑", "宋体", "Arial Narrow";
	
	}
	table th{
	padding:0px;
	border:none;
	}
	table td{
	padding:0px;
	
	}
	.table{
		font-size: 12px;
		text-align: center;
		line-height: 30px;

	}

	.top .line{
		width: 100%;
		height: 0px;
		border-bottom: 1px dashed #999;
		margin-left: 0;
		margin-top:0px; 
	}
	.top .text{
		width: 100%;
		height: 30px;
		margin-top:0px; 
		margin-left: 0;
		line-height: 30px;
	}
	.top{
		width: 90%;
		height:auto;
		margin-left: 5%;
		margin-top:3px;
		border-left:1px dashed #999;
		border-right:1px dashed #999;
		margin-bottom: 1%;
	}

	.button{
		width: 80%;
		height: 80%;
		border-radius: 9px 9px;
		background: #87CEFF;
		border: 0.5px solid  #87CEFA;

	}
	.frozen{
		width: 80%;
		height: 80%;
		border-radius: 9px 9px;
		background: #87CEFF;
		border: 0.5px solid  #87CEFA;

	}
	.page span,a{
		padding-left:2px;
		padding-right:2px;
	}
	.tips{
        position:fixed;
        top:-10px;
        background: rgba(41,81,196,0.5);
        width:100%;
        color:#fff;
        font-size:16px;
        text-align: left;
        text-indent: 2em;
        line-height:30px;
        z-index: 99;
        display: none;
    }
</style>
<script src="http://www.jq22.com/jquery/1.4.4/jquery.min.js"></script>
</block>
<block name="body">
<p class="tips"></p>


<div style="width:90%;margin:auto;margin-top:5%">

	<if condition="$pid eq 0">
		<else/>
			<p>我的上级:{$pid.shop_name}</p>
		
	</if>
	


	<empty name="list">
		<table class="table" border="1" bordercolor="#EDEDED" cellspacing="0" cellpadding="0" >
			<thead bgcolor="#F8F8FF" style="font-weight: 900;">
				<tr height="25">
					<td>商户编号</td>
					<td>姓名</td>
					<td width="20%">下级费率</td>
					<td>提现状态</td>
					<td>获得分润</td>
					<td>状态</td>
				</tr>
			</thead>
			<tbody>
				<tr height="25">
					<td colspan="16">还没有成员哦，快去使用推广码添加吧!</td>
					
				</tr>
			</tbody>


		</table>

	<else/>
		<table class="table" width="100%" border="1" bordercolor="#EDEDED" cellspacing="0" cellpadding="0" >
			<thead bgcolor="#F8F8FF" style="font-weight: 900;">
				<tr height="30">
					<td>商户编号</td>
					<td>姓名</td>
					<td width="20%">下级费率</td>
					<td>提现状态</td>
					<td>获得分润</td>
				</tr>
			</thead>
			<tbody>

				<tr height="30" style="font-size:11px;">
					<td colspan="2">全部修改为：</td>

					<td  width="20%"><input type="text" name="up_set" id="all" style="width:90%;"></td>

					<td colspan="3"><button class="all" style="width:30%;margin:auto;text-align:center">确 定</button></td>
				</tr>
				<foreach name="list" item="vo">

					<tr height="30" style="font-size:11px;">


						<input type="hidden" value="{$vo.uid}" name="uid"   class="uid" >


						<td >{$vo.yh_uid}</td>
						<td>

							<php>
								if(empty($vo['identify'])){
									$one=D('Member')->where("uid=".$vo['uid'])->find();
									echo $one['nickname'];
								}else{
									echo $vo['name'];
								}
							</php>

						</td>
						<php>
							$ga=D('Gather')->where("uid=".$vo['uid'])->find();
						</php>
						<td width="20%">
							
							<input type="text" value="{$ga.up_set}" name=" up_set"   class=" up_set"  style="width:90%;">
						</td>
						<td>
							<php>
								
								if($ga['frozen']==0){
									echo '<button class=" frozen">冻结</button>';
								}else{
									echo '<button class=" frozen">正常</button>';
								}
							</php>
						</td>

						<td>
							<php>
								$uid=$vo['uid'];
								$_this=D('Ptyh')->where("uid=$uid")->find();
								$shou=$_this['name'].'-'.$_this['shop_name'];
								$divide=D('Dividend')->where("shou='$shou'")->sum('divide');
								echo $divide;
							</php>
						</td>


					</tr>
				</foreach>
			</tbody>


		</table>
		

	</empty>


<div class="page"  style="float:left;width:auto;height:30px;opacity:1;position:relative">{$_page}</div>
<p></p>
<p style="font-size:12px;line-height:15px;margin-top:5px;height:15px;">提示：</p>
<p style="font-size:12px;line-height:15px;margin-top:5px;height:15px;">1、您可修改下级费率，您与下级的费率差为您的分润值。</p>
<!-- <p style="font-size:12px;line-height:15px;margin-top:5px;height:15px;">2、您发现你下级商户存在异常可操作商户冻结。</p> -->


</div>
</block>



<block name="script">
	<script type="text/javascript">
		$('.button').click(function(){

			var _this=$(this);
			var text=_this.html()
			var uid=_this.parent().parent().find('.uid').val();
			if(text=='关闭'){
				var status=1;
			}else{
				var status=0;
			}
			$.ajax({
				type:'post',
				data:{'uid':uid,'status':status},
				url:"{:U('team')}",
				success:function(m){
					if(m>0){
						// 成功
						if(status==1){
							_this.html('开启')
						}else{
							_this.html('关闭')
						}
						
					}else{

						$('.tips').html('修改失败')
						$('.tips').show()
                        setTimeout(function(){
                            $('.tips').hide()
                            
                        },3000)
					}
				}
			})
		})

		$('.up_set').change(function(){

			var _this=$(this);
			var uid=_this.parent().parent().find('.uid').val();
			var up_set=_this.val();
			$.ajax({
				type:'post',
				data:{'uid':uid,'up_set':up_set},
				url:"{:U('team2')}",
				success:function(m){
					if(m>0){
						// 成功
							_this.val(up_set)
							$('.tips').html('修改成功')
							$('.tips').show()
	                        setTimeout(function(){
	                            $('.tips').hide()
	                            
	                        },3000)
						
					}else if(m==0){
						$('.tips').html('修改失败')
						$('.tips').show()
                        setTimeout(function(){
                            $('.tips').hide()
                            
                        },3000)
					}else{
						$('.tips').html(m)
						$('.tips').show()
                        setTimeout(function(){
                            $('.tips').hide()
                            
                        },3000)
					}
				}
			})
		})

		$('.all').click(function(){

			var up_set=$('#all').val();
			$.ajax({
				type:'post',
				data:{'uid':1,'up_set':up_set},
				url:"{:U('team2')}",
				success:function(m){
					if(m>0){
						// 成功
							$('.tips').html('修改成功')
							$('.tips').show()
	                        setTimeout(function(){
	                            $('.tips').hide()
	                            location.reload()
	                        },3000)
							
						
					}else if(m==0){
						$('.tips').html('修改失败')
						$('.tips').show()
                        setTimeout(function(){
                            $('.tips').hide()
                            
                        },3000)
					}else{
						$('.tips').html(m)
						$('.tips').show()
                        setTimeout(function(){
                            $('.tips').hide()
                            
                        },3000)
					}
				}
			})
		})
	</script>


	
</block>